//# sourceURL=http://uMapApp/UI/QueryNode
define([
    "mhjs/mhjs",
    "uMap/uMap"
], function (
    mhjs,
    uMap
) {

    function QueryNode(option) {

        var _this = this;
        _this.isOpened = false;

        mhjs.Div.call(_this, option);
        _this.addClass("queryNode");

        _this.on("send", function () {
            _this.addClass("send");
            console.log(_this.title + " > 开始");
        });

        _this.on("loaded", function () {
            _this.addClass("loaded");
            console.log(_this.title + " > 完成");
        });

        _this.on("error", function (error) {
            _this.addClass("error");
            console.log(_this.title + " > 错误:" + error);
        });

    }

    var _class = QueryNode;
    mhjs.Inherit(_class, mhjs.Div);


    Object.defineProperties(_class.prototype, {
        "request": {
            get: function () {
                return this._request;
            },
            set: function (request) {
                var _this = this;
                _this._request = request;
                _this.title = "[服务]" + " : " + request.server.title + " : " + request.title;

                _this.request.on("send", function () {
                    _this.trigger("send");
                });

                _this.request.on("loaded", function () {
                    _this.trigger("loaded");
                });

                _this.request.on("error", function (error) {
                    _this.trigger("error",error);
                });

            }
        },
        "title"  : {
            get: function () {
                return this._title;
            },
            set: function (title) {
                var _this = this;
                _this._title = title;
                _this.attr("title", title);
            }
        },
        "open"   : {
            value: function () {
                var _this = this;
                _this.isOpened = true;
                _this.addClass("open");
            }
        },
        "close"  : {
            value: function () {
                var _this = this;
                _this.isOpened = false;
                _this.removeClass("open");
            }
        },
        "toggle" : {
            value: function () {
                var _this = this;
                if (_this.isOpened) {
                    _this.close();
                } else {
                    _this.open();
                }
            }
        }
    });

    return _class;

});